package com.yao.presenter;

import android.arch.lifecycle.LifecycleOwner;
import com.base.mvp.IModel;
import com.base.mvp.IView;
import com.yao.AppConfig;
import com.yao.http.Result;
import com.yao.presenter.bean.AppBean;
import com.yao.presenter.bean.BannerBean;
import com.yao.presenter.bean.IndexDataBean;
import io.reactivex.Flowable;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.Headers;
import retrofit2.http.POST;

import java.util.List;

public interface IndexContract {

    interface Model extends IModel<Api> {
        Flowable<Result<List<IndexDataBean>>> getIndexData();

        Flowable<Result<List<BannerBean>>> getIndexBanner();

        Flowable<Result<AppBean>> getAppUpdateInfo(String apkVersion,String sysVersion);
    }

    interface View extends IView {
        void onSuccess(List<IndexDataBean> result);

        void onSuccessBanner(List<BannerBean> data);

        void onSuccessUpdate(AppBean appBean);

        void onFail(int code, String msg);

        LifecycleOwner bindLifecycleOwner();
    }

    interface Presenter {
        void getData(String apkVersion,String sysVersion);
    }

    interface Api {
        @Headers("Tag:" + AppConfig.Http.API_INDEX_DATA)
        @POST(AppConfig.Http.API_INDEX_DATA)
        Flowable<Result<List<IndexDataBean>>> getIndexData();

        @Headers("Tag:" + AppConfig.Http.API_INDEX_BANNER)
        @POST(AppConfig.Http.API_INDEX_BANNER)
        Flowable<Result<List<BannerBean>>> getIndexBanner();

        @Headers("Tag:" + AppConfig.Http.API_UPDATE)
        @POST(AppConfig.Http.API_UPDATE)
        Flowable<Result<AppBean>> getAppUpdateInfo(@Body RequestBody body);
    }
}
